/* USER CODE BEGIN Header */
/**
 ******************************************************************************
 * File Name          :
 * Description        :
 ******************************************************************************
 * @attention
 *
 *
 ******************************************************************************
 */
/* USER CODE END Header */

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "DriverPara.h"
#include "utils_math.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
#define USE_RPARMETER_HEAD 0xAABBCCDD
/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */

/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */

/* USER CODE END FunctionPrototypes */

/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
void Default_UserParameter(UserParaUnion *Parameters)
{
  if (Parameters->Para.DataHead != USE_RPARMETER_HEAD)
  {
    Parameters->Para.Pid_Q.kp = 0.5f;
    Parameters->Para.Pid_Q.ki = 0.1f;
    Parameters->Para.Pid_Q.kd = 0.0f;
    Parameters->Para.Pid_Q.upper = 5.0f;
    Parameters->Para.Pid_Q.lower = -5.0f; // ampere

    Parameters->Para.Pid_D.kp = 0.5f;
    Parameters->Para.Pid_D.ki = 0.1f;
    Parameters->Para.Pid_D.kd = 0.0f;
    Parameters->Para.Pid_D.upper = 5.0f;
    Parameters->Para.Pid_D.lower = -5.0f; // ampere

    Parameters->Para.Pid_V.kp = 1.86f;
    Parameters->Para.Pid_V.ki = 0.0019f;
    Parameters->Para.Pid_V.kd = 0.0093f;
    Parameters->Para.Pid_V.upper = 5.0f;
    Parameters->Para.Pid_V.lower = -5.0f; // ampere

    Parameters->Para.Pid_P.kp = 0.2f;
    Parameters->Para.Pid_P.ki = 0.0f;
    Parameters->Para.Pid_P.kd = 0.0f;
    Parameters->Para.Pid_P.upper = 500.0f;
    Parameters->Para.Pid_P.lower = -500.0f;// velocity

    Parameters->Para.DataHead = USE_RPARMETER_HEAD;
    Parameters->Para.ProtocolType = ProtocolMinta;

    Parameters->Para.CANID = 1;
    Parameters->Para.BASEID = 0;
    Parameters->Para.BrakeLevel = 1;
    Parameters->Para.ExternalEncoder = false;

    Parameters->Para.PositionOffset = 0.0f;
    Parameters->Para.PositionUpper = 10.0f * TWO_PI;
    Parameters->Para.PostionLower = -10.0f * TWO_PI;
    Parameters->Para.VelocityLimit = 2000.0f;
    Parameters->Para.IQLimit = 2.0f;
    Parameters->Para.TS_AccSpeed = 1000.0f;
    Parameters->Para.TS_DecSpeed = -1000.0f;
    Parameters->Para.TS_VelocityLimit = 2000.0f;
    Parameters->Para.TP_AccSpeed = 1000.0f;
    Parameters->Para.TP_DecSpeed = -1000.0f;
    Parameters->Para.TP_VelocityLimit = 2000.0f;

    Parameters->Para.UpperMotorTmp = 90;
    Parameters->Para.RcoverMotorTmp = 80;
    Parameters->Para.UpperInvTmp = 70;
    Parameters->Para.RcoverInvTmp = 60;
    Parameters->Para.Stall_J_Limit = 10000;
    Parameters->Para.SoftPosLimitEnable = false;
    Parameters->Para.HearBeatEnable = false;
    Parameters->Para.HearBeatTime = 1000; // ms

    Parameters->Para.SNCode.Code1 = 0;
    Parameters->Para.SNCode.Code2 = 0;
    Parameters->Para.SNCode.Code3 = 0;
    Parameters->Para.SNCode.Code4 = 0;
  }
}

/* USER CODE END Application */
